package com.tiny.cqzcp.main.thread;

import com.tiny.cqzcp.pojo.RecNumber;
import com.tiny.cqzcp.service.RecommendService;
import com.tiny.cqzcp.utils.ToolkitUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;

/**
 * @Classname RecoRunnable
 * @Description TODO
 * @Date 2021/3/11 22:52
 * @auther Administrator
 */
public class RecommendRunnable implements Runnable {

    private List<String> list;
    private RecommendService recService;

    public RecommendRunnable(List<String> list,RecommendService recService){
        this.list = list;
        this.recService = recService;
    }

    @Override
    public void run() {
        List<RecNumber> results = new ArrayList<>();
        //人为将40变为39+1  39平分组合后将1加到新的里面去组成27
        List<String> data = ToolkitUtil.cutList(list,2,3);
        for(int i=0;i<data.size();i++){
            Random random = new Random();
            String[] s = data.get(i).split(",");
            int index = random.nextInt(s.length);
            String str = s[index];
            List<String> strings = new ArrayList<>(Arrays.asList(s));
            strings.remove(index);
            String join = String.join(",", strings);
            List<String> a11List = Arrays.asList(join.split(","));
            List<String> data11 = ToolkitUtil.cutList(a11List,2,3);
            for(int j=0;j<data11.size();j++){
                List<String> a111List = Arrays.asList((data11.get(j)+","+str).split(","));
                List<String> data111 = ToolkitUtil.cutList(a111List,2,3);

                for(int k=0;k<data111.size();k++){
                    List<String> a1111List = Arrays.asList(data111.get(j).split(","));
                    List<String> data1111 = ToolkitUtil.cutList(a1111List,2,3);
                    //12码
                    for(String number : data1111){
                        RecNumber recNumber = new RecNumber();
                        recNumber.setRnumbersStatus(0);
                        recNumber.setRnumbersType("0");
                        recNumber.setRnumbersContent(number);
                        results.add(recNumber);
                    }
                    /*//10码
                    for(int l=0;l<data1111.size();l++){
                        List<String> a11111List = Arrays.asList(data1111.get(l).split(","));
                        List<String> data11111 = ToolkitUtil.cutList(a11111List,5,6);
                        for(String number : data11111){
                            RecNumber recNumber = new RecNumber();
                            recNumber.setRnumbersStatus(0);
                            recNumber.setRnumbersType("1");
                            recNumber.setRnumbersContent(number);
                            results.add(recNumber);
                        }
                    }
                    //9码
                    for(int l=0;l<data1111.size();l++){
                        List<String> a11111List = Arrays.asList(data1111.get(l).split(","));
                        List<String> data11111 = ToolkitUtil.cutList(a11111List,3,4);
                        for(String number : data11111){
                            RecNumber recNumber = new RecNumber();
                            recNumber.setRnumbersStatus(0);
                            recNumber.setRnumbersType("2");
                            recNumber.setRnumbersContent(number);
                            results.add(recNumber);
                        }
                    }*/
                }
            }
        }
        if(!results.isEmpty()){
            recService.batchInsert(results);
        }
    }

}
